package com.finger.forest.adapter;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.Button;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.finger.forest.CollectionResourceDetailActivity;
import com.finger.forest.CollectionRoadDetailActivity;
import com.finger.forest.R;
import com.finger.forest.model.FireInfoModel;
import com.finger.forest.model.ResourceModel;

import java.util.List;

/**
 * @author jzj
 * @date 2021/1/27
 * @desc
 */
public class CollectionListResourceAdapter extends BaseQuickAdapter<ResourceModel, BaseViewHolder> {

    private static final String TAG = "CollectionListResourceAdapter";

    private Context context;

    public CollectionListResourceAdapter(int layoutResId, @Nullable List<ResourceModel> data, Context context) {
        super(layoutResId, data);
        this.context = context;
    }

    @Override
    protected void convert(BaseViewHolder helper, ResourceModel item) {
        helper.setText(R.id.tv_resource_name, item.getName());
        helper.setText(R.id.tvLocation, item.getLongitude() + "," + item.getLatitude());
        helper.setText(R.id.tvRemark, item.getRemark());
        helper.setText(R.id.tvType, item.getResouTypeName());

        //查看详情
        Button btn_resource_detail = helper.getView(R.id.btn_resource_detail);
        btn_resource_detail.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(context, CollectionResourceDetailActivity.class);
                intent.putExtra("id",item.getId());
                context.startActivity(intent);
            }
        });
    }
}
